<div class="widget">       


                <?php //foreach ($languages as $language){
                $language = LanguageTable::getInstance()->find($language_id);
                ?>
				<?php if ($language->getId() != sfConfig::get('app_english')){?>
					 <form id="form_<?php echo $language->getId()?>" action="frontend_labels/saveTranslation?language_id=<?php echo $language->getId()?>">
						<div class="head">
						<h5 class="iFrames" ><?php echo $language->getName()?> Labels</h5> 
						
						</div>					 
						<table cellpadding="0" cellspacing="0" border="0" class="display" id="table_<?php echo $language->getId() ?>">
							<thead>
								<tr>
									<th>English Label</th>
									<?php if ($language->getId() != sfConfig::get('app_english')){ ?>
									<th>Translation</th>
									<?php } ?>
														
								</tr>
							</thead>
							<tbody>
							<?php foreach ($labels as $label){ ?>
								<tr class="gradeA">
									<td><?php echo $label->getName(); ?></td>
									<?php 
									$translated_label = FrontendLabelsTable::getInstance()->getTranslation($label->getId(), $language->getId());
									$translation = $translated_label != null ? utf8_decode($translated_label->getName()) :  "";
									?>
									<?php if ($language->getId() != sfConfig::get('app_english')){ ?>
									<td><input style="font-size:12px; height:25px; width:95%" type="text" name="<?php echo $label->getId()?>_<?php echo $language->getId()?>" value="<?php echo $translation?>"> </td>
									<?php } ?>
								</tr>
								<?php }?>
							</tbody>
						</table> 	
						<input type="button" value="Save <?php echo $language->getName()?> Translations" class="greyishBtn submitForm" onclick="saveTranslations('<?php echo $language->getId() ?>')" />
						</form>				 
				<?php
				}
				else{
					?>
                <div id="tab<?php echo sfConfig::get('app_english') ?>" class="tab_content" style="padding:0">
				<div class="head">
				<h5 class="iFrames">English Labels</h5>
				</div>
					<table cellpadding="0" cellspacing="0" border="0" class="display" id="table_<?php echo sfConfig::get('app_english')?>">
						<thead>
							<tr>
								<th>Label</th>
								<th>Actions</th>
							</tr>
						</thead>
						<tbody>
						<?php foreach ($labels as $label){ ?>
							<tr class="gradeA">
								<td><?php echo $label->getName(); ?></td>
								<td>
								<div style="clear: both;">
								<div style="float: left;"><img style="cursor: pointer"
									src="<?php echo image_path("icons/color/notebook.png")?>"
									onclick="$.ajax({type: 'POST', url: '<?php echo url_for('frontend_labels/show?id=' . $label->getId() )?>', script:true, cache:false, success: function(data) {  $('#label_div').html(data);} });" )) />
								</div>
								<?php if ($sf_user->getAttribute('rol_id') == sfConfig::get('app_admin')){?>
								<div style="float: left; margin-left: 5px"><img
									style="cursor: pointer"
									src="<?php echo image_path("icons/color/cross.png")?>"
									onclick="jConfirm('Are you sure you want to delete the selected Label?', 'Confirmation Dialog', function(r){if (!r){return false} else {$.ajax({type: 'POST', url: '<?php echo url_for('frontend_labels/delete?id=' . $label->getId() )?>', script:true, cache:false, success: function(data) { refreshTabs(data);} })}});" )) />
								</div>
								<?php }?></div>
								</td>
							</tr>
							<?php }?>
						</tbody>
					</table>                
                
                
                </div>					
					<?php 
				}
				//}?>   

            
            <div class="fix"></div>	 
</div>
<script>
<?php //foreach ($languages as $language){?>
var oTable_<?php echo $language->getId()?> = null;
<?php //} ?>
function saveTranslations(language_id){
	var url_str = '<?php echo url_for('frontend_labels/saveTranslation') ?>';
	url_str += '?language_id=' +  language_id;

	var oTableName = eval("oTable_" + language_id);
	var sData = $('input', oTableName.fnGetNodes()).serialize();
	var str=$('form#form_' + language_id).serialize();

	    $.ajax({type: 'POST', url: url_str, script:true, cache:false, data:  sData,
            success: function(data) {
                $('#translation_success').show('slow');
             } });
}


	<?php // foreach ($languages as $language){?>
	    	oTable_<?php echo $language->getId()?> = $('#table_<?php echo $language->getId()?>').dataTable({
	    		"bJQueryUI": true,
	    		"sPaginationType": "full_numbers",
	    		"sDom": '<""f>t<"F"lp>',
	    		"bDestroy": true
	    	});
	<?php //} ?>

	function refreshTabs(data){
		$('#label_container_div').html(data); 
		//$("div[class^='widget']").simpleTabs();
		//$("select, input:checkbox, input:radio, input:file").uniform();
	}
</script>
